package com.bamboo.ossservice.controller;

import com.bamboo.commonutils.ResponseEntity;
import com.bamboo.ossservice.service.OssService;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;

/**
 * @author jack.wu
 * @version 1.0
 * @date 2020-07-04
 */
@RestController
@RequestMapping("/eduoss/fileoss")
@CrossOrigin
public class OssController {

    @Resource
    private OssService ossService;

    /**
     * 上传头像
     *
     * @param file 头像文件
     * @return url
     */

    @PostMapping
    public ResponseEntity uploadOssFile(MultipartFile file) {

        String url = ossService.uploadFileAvatar(file);
        return ResponseEntity.ok().data("url", url);
    }

}


